/**
 * Created by zhtt on 2016/12/1.
 */
var util={};
util.regStartLetters =function(str){
    var reg=/^[A-Z]_*\w*/;
    return reg.test(str);
};
util.indexOf=function(obj,v){
    if(typeof obj=="string"){
        return obj.indexOf(v);
    }else if(typeof obj=="object"){
        if(obj){
            for(var i= 0,j=obj.length;i<j;i++){
                if(v==obj[i]){
                    return i;
                }
            }
            return -1;
        }else{
            return -1;
        }
    }else{
        return -1;
    }
};
util.remarkToJson=function(remarkStr){
    try{
        var remark=$.parseJSON(remarkStr.replace(/\'/g,'"'));
        return remark;
    }catch (e){
        return false;
    }
};
util.sortAuthoritys=function(a,b){
    if(typeof a.remark=='undefined'){
        return -1;
    }else if(typeof b.remark=='undefined'){
        return 1;
    }
    var aa=util.remarkToJson(a.remark);
    var bb=util.remarkToJson(b.remark);
    if(typeof aa=='boolean'){
        return -1;
    }else if(typeof bb=='boolean'){
        return 1;
    }
    var aaa=aa.order;
    var bbb=bb.order;
    if(typeof aaa=='undefined'){
        return -1;
    }else if(typeof bbb=='undefined'){
        return 1;
    }
    return aaa-bbb;
};
Array.prototype.indexOf = function(val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) return i;
    }
    return -1;
};
Array.prototype.remove = function(val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};
